﻿<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:MediaBrowser.CustomControls"
    xmlns:EffectsLib="clr-namespace:EffectsLib;assembly=EffectsLib"
    xmlns:MouseCursors="clr-namespace:MediaBrowser.CustomControls.MouseCursors;assembly=MediaBrowser.CustomControls"
    >
    <Style TargetType="{x:Type local:ImageButton}">
        <Setter Property="MouseCursors:CursorSet.Cursor" Value="Hand"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:ImageButton}">
                    <ControlTemplate.Resources>
                        <Storyboard x:Key="AnimOnImgButton">
                            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="GridContainer" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)">
                                <SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
                                <SplineDoubleKeyFrame KeyTime="00:00:00.1000000" Value="1.15"/>
                            </DoubleAnimationUsingKeyFrames>
                            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="GridContainer" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
                                <SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
                                <SplineDoubleKeyFrame KeyTime="00:00:00.1000000" Value="1.15"/>
                            </DoubleAnimationUsingKeyFrames>
                            <!--<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="GridContainer" Storyboard.TargetProperty="(UIElement.Effect).(DropShadowEffect.BlurRadius)">
                                <SplineDoubleKeyFrame KeyTime="00:00:00" Value="5"/>
                                <SplineDoubleKeyFrame KeyTime="00:00:00.1000000" Value="20"/>
                            </DoubleAnimationUsingKeyFrames>-->
                        </Storyboard>
                        <Storyboard x:Key="AnimOffImgButton">
                            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="GridContainer" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)">
                                <SplineDoubleKeyFrame KeyTime="00:00:00" Value="1.15"/>
                                <SplineDoubleKeyFrame KeyTime="00:00:00.1000000" Value="1"/>
                            </DoubleAnimationUsingKeyFrames>
                            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="GridContainer" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
                                <SplineDoubleKeyFrame KeyTime="00:00:00" Value="1.15"/>
                                <SplineDoubleKeyFrame KeyTime="00:00:00.1000000" Value="1"/>
                            </DoubleAnimationUsingKeyFrames>
                            <!--<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="GridContainer" Storyboard.TargetProperty="(UIElement.Effect).(DropShadowEffect.BlurRadius)">
                                <SplineDoubleKeyFrame KeyTime="00:00:00" Value="20"/>
                                <SplineDoubleKeyFrame KeyTime="00:00:00.1000000" Value="5"/>
                            </DoubleAnimationUsingKeyFrames>-->
                        </Storyboard>
                    </ControlTemplate.Resources>
                    <Grid x:Name="GridContainer" RenderTransformOrigin="0.5,0.5">
                        <!--<Grid.Effect>
                            <DropShadowEffect/>
                        </Grid.Effect>-->
                        <Grid.RenderTransform>
                            <TransformGroup>
                                <ScaleTransform/>
                                <SkewTransform/>
                                <RotateTransform/>
                                <TranslateTransform/>
                            </TransformGroup>
                        </Grid.RenderTransform>
                        <Image Source="{TemplateBinding Source}" Stretch="Fill" x:Name="img">
                            <Image.Effect>
                                <EffectsLib:GreyscaleEffect x:Name="greyscaleEffect"/>
                            </Image.Effect>
                        </Image>
                        <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
						VerticalAlignment="{TemplateBinding VerticalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" RecognizesAccessKey="True"/>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsFocused" Value="True"/>
                        <Trigger Property="IsDefaulted" Value="True"/>
                        <Trigger Property="IsMouseOver" Value="true">
                            <Trigger.ExitActions>
                                <BeginStoryboard Storyboard="{StaticResource AnimOffImgButton}" />
                            </Trigger.ExitActions>
                            <Trigger.EnterActions>
                                <BeginStoryboard Storyboard="{StaticResource AnimOnImgButton}" />
                            </Trigger.EnterActions>
                        </Trigger>
                        <Trigger Property="IsPressed" Value="True"/>
                        <Trigger Property="IsEnabled" Value="True">
                            <Setter Property="Effect" TargetName="img">
                                <Setter.Value>
                                    <EffectsLib:GreyscaleEffect DesaturationFactor="1"/>
                                </Setter.Value>
                            </Setter>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Effect" TargetName="img">
                                <Setter.Value>
                                    <EffectsLib:GreyscaleEffect DesaturationFactor="0"/>
                                </Setter.Value>
                            </Setter>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>
